package com.timothy.junk;

import java.util.ArrayList;
import java.util.List;
import com.timothy.junk.adapter.JunkNotifyAdaptor;
import com.timothy.junk.common.bean.JunkNotify;
import android.app.ListActivity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;

public class JunkNotifyList extends ListActivity {

    Context mContext;
    SharedPreferences sp;
    JunkNotifyAdaptor adaptor ;
    
    String[] junkNames;
    List<JunkNotify> junkNotifyList = new ArrayList<JunkNotify>();;
    
    public void loadData(){
    	junkNames = this.getResources().getStringArray(R.array.junks);
    	int i=1;
    	for(String junkName: junkNames){
    		JunkNotify jNotify = new JunkNotify();
    		
    		jNotify.setId(i);
    		jNotify.setName(junkName);
    		jNotify.setIfNotify(false);
    		jNotify.setInterval(30);
    		junkNotifyList.add(jNotify);
    		i++;
    	}
    }
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.junk_notify_list);
        mContext = getApplicationContext();
        sp = this.getSharedPreferences("GFundApp",MODE_PRIVATE);
        
        loadData();
        
        ActivityManage.add(this);
        adaptor = new JunkNotifyAdaptor(mContext, junkNotifyList,sp); 
        setListAdapter(adaptor);
    }
}
